package com.movie.dto;

import lombok.Data;

@Data
public class ResponseDTO<T> {
    private int status; // 200 成功，400 请求错误，500 服务器错误
    private String message;
    private T data;

    public static <T> ResponseDTO<T> success(T data, String 评分成功) {
        ResponseDTO<T> r = new ResponseDTO<>();
        r.setStatus(200);
        r.setMessage("success");
        r.setData(data);
        return r;
    }

    public static <T> ResponseDTO<T> error(String message, int status) {
        ResponseDTO<T> r = new ResponseDTO<>();
        r.setStatus(status);
        r.setMessage(message);
        return r;
    }

    public static <T> ResponseDTO<T> error(String message) {
        ResponseDTO<T> r = new ResponseDTO<>();
        r.setStatus(400); // 默认状态码
        r.setMessage(message);
        return r;
    }

}
